﻿using System;
using Citi.Scheduler.Domain;

namespace Citi.Scheduler.WebUi.Models
{
    public class RoutineExecutionHistoryModel : ModelBase<RoutineExecutionHistoryModel, RoutineExecutionHistory>
    {
        public DateTime Date { get; set; }
        public string Details { get; set; }
        public int RoutineExecutionId { get; set; }
        public RoutineExecutionStatus Status { get; set; }

        public string RoutineName
        {
            get
            {
                return new RoutineExecution().SelectById<RoutineExecution>(RoutineExecutionId).Routine.Name;
            }
        }

        public string MachineHostName
        {
            get
            {
                var machine =  new RoutineExecution().SelectById<RoutineExecution>(RoutineExecutionId).Machine;
                return machine != null ? machine.HostName : null;
            }
        }
    }
}